<template>
  <el-header>
    <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
      <el-menu-item index="user">用户</el-menu-item>
      <el-menu-item index="word">词典</el-menu-item>
      <el-menu-item index="category">分类</el-menu-item>
      <el-menu-item index="hotnew">热榜</el-menu-item>
    </el-menu>
  </el-header>
</template>
<script lang="ts" setup>
import router from '@/router/manager'
import { ref } from 'vue'
import { useRoute } from 'vue-router'

const route = useRoute()
const activeIndex = ref((route.name as string) || 'user')
const handleSelect = (key: string) => {
  router.replace({ name: key })
}
</script>
<style lang="scss" scoped>
.el-header {
  height: 50px;
  border-bottom: 1px solid #cccccc;

  .el-menu {
    height: 50px;
  }
}
</style>
